package com.gzp.service.impl;

import java.util.Arrays;
import java.util.List;

import com.gzp.pojo.UserAddress;
import com.gzp.service.UserService;

/**
 * 本地存根类，当调用提供者服务发生错误时，可返回个默认值。 相当于熔断器的服务降级。
 * 
 * @author Administrator
 *
 */
public class StubUserServiceImpl implements UserService {

	private UserService userService;

	public StubUserServiceImpl(UserService userService) {
		super();
		this.userService = userService;
	}

	@Override
	public List<UserAddress> findAllAddress(String userId) {
		try {
			System.out.println("-----本地存根类--------");
			return userService.findAllAddress(userId);
		} catch (Exception e) {
			return Arrays.asList(new UserAddress("0", "默认地址", "0"));
		}
	}

}
